#import "ALHighlightingTextFieldCell.h"


@interface ALHighlightingTextFieldCell (ALHighlightingTextFieldCellPrivateMethods)
-(void)setAttributedStringWithString_:(NSString *)aString;
@end


@implementation ALHighlightingTextFieldCell

-(void)setObjectValue:(id <NSCopying>)obj {
	if (![(NSObject *)obj isKindOfClass:[NSString class]]) {
		[super setObjectValue:obj];
		return;
	}
	[self setAttributedStringWithString_:(NSString *)obj];
}

-(BOOL)isHighlighted {
	return highlighted_;
}

-(void)setHighlighted:(BOOL)flag {
	highlighted_ = flag;
	[self setAttributedStringWithString_:[self stringValue]];
}

-(NSDictionary *)normalAttributes {
	return nil;
}

-(NSDictionary *)highlightedAttributes {
	return nil;
}

-(void)setAttributedStringWithString_:(NSString *)aString {
	NSDictionary *attributes = [self isHighlighted] ? [self highlightedAttributes] : [self normalAttributes];
	NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] initWithString:aString attributes:attributes];
	[self setAttributedStringValue:mutableString];
}

@end
